function grayImg = colorKill(rgbImg,rgbScheme)
%功能:彩色图像转为灰度图像
%   rgbImg为彩色图像,rgbScheme选择颜色模型,或输入[r,g,b],或不输入则调用默认灰度转换,或'r',或'g',或'b',
if length(size(rgbImg)) == 2
    grayImg = rgbImg;
    return
end
imgDou = im2double(rgbImg);
if (~exist('rgbScheme','var'))
    grayImg = rgb2gray(rgbImg);
    return
elseif rgbScheme == 'r'
    grayImg = imgDou(:,:,1);
    return
elseif rgbScheme == 'g'
    grayImg = imgDou(:,:,2);
    return
elseif rgbScheme == 'b'
    grayImg = imgDou(:,:,3);
    return
else
    sumrgb = sum(rgbScheme);
    r = imgDou(:,:,1) * rgbScheme(1)/sumrgb;
    g = imgDou(:,:,2) * rgbScheme(2)/sumrgb;
    b = imgDou(:,:,3) * rgbScheme(3)/sumrgb;
    grayImg = r + g + b;
end

